'use strict';
const mongoose = require('mongoose');
const config = require('../config/config.unittest.js')({});
const fs = require('fs');
const readline = require('readline');
const dayjs = require('dayjs');

let ParserBetter = require('../app/utils/rss/parser');
let parserBetter = new ParserBetter({timeout: 10000});

const UserModel = require('../app/model/User')({
  mongoose,
});
const TopicModel = require('../app/model/Topic')({
  mongoose,
});

mongoose.connect(config.mongoose.url, config.mongoose.options, function (err) {
  if (err) {
    console.error('connect to %s error: ', config.mongoose, err.message);
    process.exit(1);
  }
});

async function main() {
  let day = dayjs().subtract(1, 'days');

  const result = await TopicModel.count({tab: {$in: ['news', 'yutang']}, create_at: {$lt: day}});

  console.log(result);


  process.exit(0);
}

main();

